package day0224;

public class Student implements Comparable {

    private String name;

    private int age;

    private char gender;

    public Student(String name, int age, char gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", gender=" + gender +
                '}';
    }

    @Override
    public int compareTo(Object o) {
        if (o instanceof Student stu) {
            if (this.age == stu.age) {
                if (this.gender == stu.gender) {
                    return this.name.compareTo(stu.name);
                }
                return this.gender - stu.gender;
            }
            return this.age - stu.age;
        }
        return 0;
    }
}
